<?php

class DepositsController extends Controller
{
	public function actionIndex()
	{
		$deposit = $this->loadModel();
		$dp = $this->dp($deposit);

		$this->render('index',array(
			'model'=>$deposit,
			'dp'=>$dp,
		));
	}

	private $_model;

	public function loadModel()
	{
		if($this->_model===null)
		{
			$this->_model=Deposits::model()->findByPk(1);
			
			if($this->_model===null)
				throw new CHttpException(404,'Запрашиваемая страница не существует.');
		}
		return $this->_model;
	}

	public function dp($deposit){
		
		$dp = DepositPercents::model()->findAll('deposit_id=:deposit_id', array(':deposit_id'=>$deposit->deposit_id));
		
		return $dp;
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}